package com.ziyun.erp.web.modules.supp.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.ziyun.erp.modules.supp.entity.SellerSearchEntity;
import com.ziyun.erp.modules.supp.service.SellerSearchService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 商户（工厂）企业查询信息
 *
 * @author gaosheng
 * @email 
 * @date 2018-10-09 17:24:40
 */
@RestController
@RequestMapping("supp/sellersearch")
public class SellerSearchController {
    @Autowired
    private SellerSearchService sellerSearchService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("supp:sellersearch:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = sellerSearchService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{ssId}")
    @RequiresPermissions("supp:sellersearch:info")
    public R info(@PathVariable("ssId") Integer ssId){
        SellerSearchEntity sellerSearch = sellerSearchService.selectById(ssId);

        return R.ok().put("sellerSearch", sellerSearch);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("supp:sellersearch:save")
    public R save(@RequestBody SellerSearchEntity sellerSearch){
        sellerSearchService.insert(sellerSearch);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("supp:sellersearch:update")
    public R update(@RequestBody SellerSearchEntity sellerSearch){
        ValidatorUtils.validateEntity(sellerSearch);
        sellerSearchService.updateAllColumnById(sellerSearch);//全部更新
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("supp:sellersearch:delete")
    public R delete(@RequestBody Integer[] ssIds){
        sellerSearchService.deleteBatchIds(Arrays.asList(ssIds));

        return R.ok();
    }

}
